package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.ParamHolidaysDTO;
import com.hzeport.bgs22emduty.entity.ParamHolidays;
import com.hzeport.bgs22emduty.entity.ParamLeader;
import com.hzeport.bgs22emduty.entity.ParamSmsTemplate;
import com.hzeport.bgs22emduty.outbound.ParamLeaderRepository;
import com.hzeport.bgs22emduty.service.ParamLeaderService;
import com.hzeport.bgs22emduty.vo.ParamHolidays.ParamHolidaysSaveVO;
import com.hzeport.bgs22emduty.vo.ParamLeader.ParamLeaderListVO;
import com.hzeport.bgs22emduty.vo.ParamLeader.ParamLeaderSaveVO;
import com.hzeport.bgs22emduty.vo.ParamLeader.ParamLeaderdetailVO;
import com.hzeport.bgs22emduty.vo.base.PageVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@AllArgsConstructor
@RequestMapping("/paramleader")
@Api(value = "paramleader", tags = "带班领导表")
@Slf4j
public class ParamLeaderController {

    @Resource
    private ParamLeaderService paramLeaderService;
    @Resource
    private LoginCompoentService loginCompoentService;
    @ApiOperation(value = "列表")
    @RequestMapping(value = "list",method = RequestMethod.POST)
    public BaseResult<Page<ParamLeaderListVO>> list(@RequestBody PageVO pageVO) throws Exception {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramLeaderService.list(pageVO,userInfo);
    }

    @ApiOperation(value = "获取详情")
    @RequestMapping(value = "detail",method = RequestMethod.GET)
    public BaseResult<ParamLeaderdetailVO> detail(@RequestParam("id") String id){
        return paramLeaderService.detail(id);
    }

    @ApiOperation(value = "保存")
    @PostMapping("/save")
    @OperLog( systemName = "DBLD", description = "DBBC")
    public BaseResult save(@RequestBody ParamLeaderSaveVO paramHolidaysSaveVO) throws Exception {
        UserInfoDetailVO userInfo = loginCompoentService.getUserInfo();
        return paramLeaderService.saveData(paramHolidaysSaveVO,userInfo);
    }

}
